import { defHttp } from "/@/utils/http/axios"

enum Api {
  updateUser = "/system-service/user/me/updateProfile",
  updateAccount = "/system-service/user/me/updateAccount",
  getUserInfo = "/system-service/user/me/getUserBaseInfo",
  changeTenantOwner = "/system-service/user/me/changeTenantOwner",

  queryNameByCodes = "/sys/position/queryByCodes",
  cancelApplyTenant = "/sys/tenant/cancelApplyTenant",
  agreeOrRefuseJoinTenant = "/sys/tenant/agreeOrRefuseJoinTenant",
}


/**
 * 用户编辑
 * @param params
 */
export const updateUser = (params) => {
  return defHttp.post({ url: Api.updateUser, params }, { isTransformResponse: false })
}

/**
 * 更新账户
 * @param params
 * @returns
 */
export const updateAccount = (params) => {
  return defHttp.post({ url: Api.updateAccount, params }, { isTransformResponse: false })
}

/**
 * 获取用户信息
 * @param params
 */
export const getUserInfo = () => {
  return defHttp.get({ url: Api.getUserInfo }, { isTransformResponse: false })
}

/**
 * 获取多个职务信息
 * @param params
 */
export const queryNameByCodes = (params) => {
  return defHttp.get({ url: Api.queryNameByCodes, params }, { isTransformResponse: false })
}

/**
 * 取消申请
 * @param params
 */
export const cancelApplyTenant = (params) => {
  return defHttp.put({ url: Api.cancelApplyTenant, data: params }, { joinParamsToUrl: true, isTransformResponse: false })
}

/**
 * 变更租户拥有者
 * @param params
 */
export const changeTenantOwner = (params) => {
  return defHttp.post({ url: Api.changeTenantOwner, params }, { isTransformResponse: false, joinParamsToUrl: true })
}

/**
 * 修改密码
 * @param params
 */
export const updateUserPassword = (params) => {
  return defHttp.post({ url: "/iam-service/user/me/updatePassword", params }, { isTransformResponse: false })
}

/**
 * 获取账号第三方信息通过第三方类型
 * @param params
 */
export const listUserThirdAccount = () => {
  return defHttp.get({ url: "/iam-service/user/me/listIdpConnect", params: {} })
}

/**
 * 绑定
 * @param params
 */
export const bindIdpConnect = (params) => {
  return defHttp.post({ url: "/iam-service/user/me/bindIdpConnect", params }, { joinParamsToUrl: true })
}
export const readyBindIdpConnect = () => {
  return defHttp.post({ url: "/iam-service/user/me/readyBindIdpConnect" })
}

/**
 * 删除第三方绑定的账号
 * @param params
 */
export const unbindIdpConnect = (params) => {
  return defHttp.post({ url: "/iam-service/user/me/unbindIdpConnect", params }, { isTransformResponse: false, joinParamsToUrl: true })
}

/**
 * 同意和拒绝加入租户
 * @param params
 */
export const agreeOrRefuseJoinTenant = (params) => {
  return defHttp.put({ url: Api.agreeOrRefuseJoinTenant, params }, { joinParamsToUrl: true })
}


/**
 * 获取登录二维码信息
 */
export function getIdpConnectQrcode(params) {
  return defHttp.post({ url: "/iam-service/connect/qrcode/gen", data: params })
}

/**
 * 监控扫码状态
 */
export function checkIdpConnectQrcode(params) {
  return defHttp.get({ url: "/iam-service/connect/qrcode/check", params }, { isTransformResponse: false })
}